#pragma warning(disable:4996)
#include<stdio.h>
//给定一个长度为 n 的非降序数组和一个非负数整数 k ，要求统计 k 在数组中出现的次数
//数据范围： 0≤n≤1000, 0≤k≤100 ，数组中每个元素的值满足 0≤val≤100
int Find(int* data, int dataLen, int k, int flag) {
    int left, right, mid;
    left = 0;
    right = dataLen - 1;
    while (left <= right)
    {
        mid = left + ((right - left) >> 1);
        if (k > data[mid])
            left = mid + 1;
        else if (k < data[mid])
            right = mid - 1;
        else {
            if (!flag) {
                if ((data[mid - 1] != k )|| (mid == left))
                    return mid;
                else   right = mid - 1;
            }
            else {
                if (((mid == right) || data[mid + 1] != k))
                    return mid;
                else   left = mid + 1;
            }
        }
    }
    return -1;
}
int GetNumberOfK(int* data, int dataLen, int k)
{
    if (dataLen == 0)
        return 0;
   int left = Find(data, dataLen, k, 0);//0左
   int right = Find(data, dataLen, k, 1);//1右   
   if (left == -1 && right == -1)
       return 0;
       return right - left + 1;
    
}
int main()
{
    int date[] = { 1,2,3,3,3,4,5 };
    int sz = sizeof(date) / sizeof(date[0]);
    int k;
    scanf("%d", &k);
    printf("%d\n", GetNumberOfK(date, sz, k));
    return 0;
}